function clearTable(tableID) {
	var table = document.getElementById(tableID);
	var rows = table.rows && table.rows.length;
	for (var i = 1; i <= rows; i++) {
		table.deleteRow(0);
	}
}

function round(v,e){
	var t = 1;
	for(;e>0;t*=10,e--);
	for(;e<0;t/=10,e++);
	return Math.round(v*t)/t;
}
function formatTime1(time) {
    var now = new Date();
    if (time) {
        now = new Date(time);
    }
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var day = ((now.getDate() < 10) ? "0" : "") + now.getDate();
    var hours = ((now.getHours() < 10) ? "0" : " ") + now.getHours();
    var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
    var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();
    now = null;
    return year + "年" + month + "月" + day + "日" + hours + minutes + seconds;
}

//数据库日期转化为JSON在页面显示
function date2String(time){
    var datetime = new Date();
    datetime.setTime(time);
    var year = datetime.getFullYear();
    var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
    var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();;
    return year + "-" + month + "-" + date;
}

function getRootPath() {
	var href = window.document.location.href;
	var pathName = window.document.location.pathname;
	var index = href.indexOf(pathName);
	var localhostPaht = href.substring(0, index);
	var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
	if (projectName != "/Hssy") {
		projectName = "";
	}
	return(localhostPaht + projectName + '/');
}

function setBaseUrl() {
	var base = document.getElementsByTagName("base");
	if (base && base[0]) {
		base[0].href = getRootPath();
	}
}